package LanQiao._15JavaB;

import java.util.Arrays;
import java.util.Scanner;

public class _3 {

    //分段sc输入
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String t = sc.nextLine();
        int n = Integer.parseInt(t);
        int[] sizes = new int[n];
        int min = sizes[0];
        String s = "";
        while (sc.hasNext()) {
            s = sc.next();
            if (s.startsWith("a")) {
                sc.nextInt();
                sizes[0]++;
            } else if (s.startsWith("s")) {
                int parseInt = sc.nextInt();
                if (sizes[parseInt] < sizes[0]) {
                    sizes[parseInt]++;
                }
            } else if (s.startsWith("q")) {
                min = sizes[0];
                for (int size : sizes) {
                    min = Math.min(min, size);
                }
                System.out.println(min);
            }
        }
    }
}
